package com.sinosoft.dsp.persistence.businessconcept;

import java.util.List;

import com.sinosoft.builder.utils.EntityAttributeType;
import com.sinosoft.dsp.persistence.businessconcept.utils.BusinessConceptContentHelper;

public abstract class AbstractBusinessConceptDomainContentEntity<T> extends
		AbstractBusinessConceptMainEntity implements
		IBusinessConceptDomainContentEntity<T> {

	protected T value;

	public void setHashCodeDataForContentBase(List<String> list) {
		list.add(getDomainConceptId());
		list.add(getDomainId());
		list.add(getDomainContentConceptId());
		list.add(getSecretLevel());
	}

	public EntityAttributeType getEntityAttributeType() {
		return EntityAttributeType.getType(getDomainContentType());
	}

	public boolean checkValue(T t) {

		if (t.getClass() == BusinessConceptContentHelper
				.getAttributeValueType(getEntityAttributeType()))
			return true;
		return false;
	}

	@Override
	public T getValue() throws Exception {
		EntityAttributeType type = getEntityAttributeType();
		try {
			if (this.value == null) {
				this.value = BusinessConceptContentHelper
						.<T> createNewAttribute(type);
			}
			return this.value;
		} catch (Exception e) {
			throw new Exception("该业务实体内容对象不接受该属性类型：" + type.getCode());
		}
	}

}
